import axios from 'axios'
 
let base = 'http://localhost:8888/';
 
export const getRequest = (url,params) => {
    return axios({
        method: 'get',
        data: params,
        transformRequest: [function (data) {
            let ret =  JSON.stringify(data);
            return ret
 
        }],
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        url: `${base}${url}`
    });
}
 
export const postRequest = (url, params) => {
    return axios({
        method: 'post',
        url: `${base}${url}`,
        data: params,
        transformRequest: [function (data) {
            // Do whatever you want to transform the data
            let ret =  JSON.stringify(data);
            //console.log(ret);
            return ret
        }],
        headers: {
            /*'Content-Type': 'application/x-www-form-urlencoded'*/
            'Content-Type': 'application/json'
        }
    });
}
 
export const putRequest = (url, params) => {
    return axios({
        method: 'put',
        url: `${base}${url}`,
        data: params,
        transformRequest: [function (data) {
            let ret =  JSON.stringify(data);
            return ret
        }],
        headers: {
            'Content-Type': 'application/json'
        }
    });
}
 
export const deleteRequest = (url, params) => {
    return axios({
        method: 'delete',
        data: params,
        url: `${base}${url}`
    });
}